{
  "name": "Case 82 - Sustainability Manager - ESG Initiative Monitor",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 9 * * 1"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        -1008,
        -208
      ],
      "id": "8c123e22-42b6-4da6-9fbe-02002dce6428",
      "name": "Weekly Schedule - Monday 9 AM"
    },
    {
      "parameters": {
        "actorId": {
          "__rl": true,
          "value": "buIWk2uOUzTmcLsuB",
          "mode": "list",
          "cachedResultName": "Linkedin Post Search Scraper (No Cookies) (harvestapi/linkedin-post-search)",
          "cachedResultUrl": "https://console.apify.com/actors/buIWk2uOUzTmcLsuB/input"
        },
        "customBody": "{\n  \"authorUrls\": [\n    \"https://www.linkedin.com/company/unilever\",\n    \"https://www.linkedin.com/company/patagonia\",\n    \"https://www.linkedin.com/company/microsoft\",\n  ],\n  \"searchQueries\": [\n    \"sustainability\",\n    \"carbon neutral\",\n    \"ESG\",\n    \"green\",\n    \"renewable\",\n    \"climate\",\n    \"net zero\"\n  ],\n  \"maxPosts\": 10,\n  \"scrapeComments\": false,\n  \"scrapeReactions\": false\n}"
      },
      "type": "@apify/n8n-nodes-apify.apify",
      "typeVersion": 1,
      "position": [
        -816,
        -208
      ],
      "id": "bc345c1c-0333-48c0-95a9-a2133d52079c",
      "name": "Scrape LinkedIn ESG Posts",
      "credentials": {
        "apifyApi": {
          "id": "TXPU4EgOj6rkzr43",
          "name": "Apify account 2"
        }
      }
    },
    {
      "parameters": {
        "resource": "Datasets",
        "datasetId": "={{ $json.defaultDatasetId }}"
      },
      "type": "@apify/n8n-nodes-apify.apify",
      "typeVersion": 1,
      "position": [
        -640,
        -208
      ],
      "id": "0ec67852-8510-4d75-ac55-ab8d6ce89bc2",
      "name": "Get Dataset Items",
      "credentials": {
        "apifyApi": {
          "id": "w5S6YBbbyUddEfQA",
          "name": "Apify account"
        }
      }
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list",
          "cachedResultName": "GPT-4o-mini"
        },
        "responses": {
          "values": [
            {
              "role": "system",
              "content": "=You are an ESG Initiative Validation Expert.\n\nAnalyze LinkedIn posts to determine if they are genuine ESG/sustainability initiatives.\n\nReturn ONLY valid JSON in this exact format:\n{\n  \"is_esg_initiative\": \"yes|no\",\n  \"confidence\": 0.95,\n  \"reason\": \"brief explanation\"\n}\n\nCriteria for \"yes\" (genuine ESG initiative):\n✅ Announces specific sustainability commitment or target\n✅ Reports progress on carbon reduction/net zero goals\n✅ Launches new green product/service\n✅ Invests in renewable energy or circular economy\n✅ Achieves sustainability certification or milestone\n✅ Shares ESG metrics or data (emissions, waste, water usage)\n✅ Partners for environmental/social impact\n✅ Updates sustainability strategy or roadmap\n✅ Announces supply chain sustainability improvements\n\nCriteria for \"no\" (NOT genuine ESG initiative):\n❌ Vague \"we care about the planet\" without specifics\n❌ Greenwashing or superficial claims\n❌ Generic Earth Day/Environment Day posts\n❌ Employee volunteering events (unless part of larger program)\n❌ Recycling tips or advice without company action\n❌ Reposting third-party content without company initiative\n❌ Awards/recognition without underlying action\n❌ Thought leadership without concrete commitments\n\nRules:\n1. confidence: 0-1 scale (0.9+ for very clear ESG initiatives)\n2. reason: 1 sentence explaining the decision\n3. Be strict - require actual measurable initiatives, not just talk\n4. Return ONLY the JSON object, no explanations"
            },
            {
              "content": "=Analyze this LinkedIn post to determine if it's a genuine ESG initiative:\n\nAuthor: {{ $json.author.name }}\nPost Date: {{ $json.postedAt.date }}\nPost Content: {{ $json.content }}\n\nReturn only JSON."
            }
          ]
        },
        "builtInTools": {},
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 2.1,
      "position": [
        -480,
        -208
      ],
      "id": "db0c2010-065a-4487-abc9-24f474155a5c",
      "name": "AI Validation Filter",
      "credentials": {
        "openAiApi": {
          "id": "ICwxUBbatsF2sDvy",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// UNIVERSAL AI RESPONSE PARSER - Same code for ALL cases\nconst items = [];\nconst input = $input.all();\n\nfunction extractJSON(text) {\n  const jsonMatch = text.match(/\\{[\\s\\S]*\\}/);\n  if (!jsonMatch) return null;\n  return jsonMatch[0];\n}\n\ninput.forEach((item, index) => {\n  try {\n    let aiText = item.json.output[0].content[0].text || '';\n    \n    // Clean markdown code blocks\n    aiText = aiText\n      .replace(/```json/gi, '')\n      .replace(/```/g, '')\n      .trim();\n    \n    // Extract JSON object\n    const jsonStr = extractJSON(aiText);\n    \n    if (!jsonStr) {\n      throw new Error('No JSON found in AI response');\n    }\n    \n    // Parse and return clean JSON\n    const parsed = JSON.parse(jsonStr);\n    items.push({ json: parsed });\n    \n  } catch (error) {\n    console.error(`Parse error for item ${index}:`, error.message);\n    // Return empty object on error - no case-specific fields\n    items.push({ json: {} });\n  }\n});\n\nreturn items;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -208,
        -208
      ],
      "id": "e7c4bddd-b94a-43a3-8e2b-b7041586bdbd",
      "name": "Parse AI Validation"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "is_esg_initiative",
              "name": "is_esg_initiative",
              "value": "={{ $json.is_esg_initiative }}",
              "type": "string"
            },
            {
              "id": "confidence",
              "name": "confidence",
              "value": "={{ $json.confidence }}",
              "type": "number"
            },
            {
              "id": "reason",
              "name": "reason",
              "value": "={{ $json.reason }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -48,
        -208
      ],
      "id": "b9a44204-9aed-4c2e-bba5-76a78bae4e2a",
      "name": "Edit Fields - Validation"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 1
          },
          "conditions": [
            {
              "id": "condition-001",
              "leftValue": "={{ $json.is_esg_initiative }}",
              "rightValue": "yes",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2,
      "position": [
        144,
        -208
      ],
      "id": "4300fc5e-c9ae-4076-aa23-1eaa108d74b7",
      "name": "Filter Only ESG Initiatives"
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list",
          "cachedResultName": "GPT-4o-mini"
        },
        "responses": {
          "values": [
            {
              "role": "system",
              "content": "=You are an ESG Intelligence Analyst.\n\nExtract structured ESG initiative information from LinkedIn posts.\n\nReturn ONLY valid JSON in this exact format:\n{\n  \"company_name\": \"Company posting the initiative\",\n  \"initiative_type\": \"Carbon Reduction|Renewable Energy|Waste Reduction|Supply Chain|Product Design|Water Conservation|Biodiversity|Social Impact|Governance|Other\",\n  \"commitment_level\": \"Target Set|In Progress|Achieved|Ongoing\",\n  \"timeline\": \"YYYY or 'By YYYY' or 'Achieved' or 'Not specified'\",\n  \"metrics_shared\": \"Specific numbers/targets mentioned (e.g., '50% reduction by 2030') or 'None'\",\n  \"investment_amount\": \"Budget/investment mentioned or 'Not specified'\",\n  \"competitive_threat\": \"High|Medium|Low - are they ahead of industry?\",\n  \"best_practice\": \"Yes|No - is this replicable/industry-leading?\"\n}\n\nExtraction Rules:\n1. company_name: Extract company name from post\n2. initiative_type: Categorize into most relevant category\n3. commitment_level:\n   - Target Set = Just announced goal/commitment\n   - In Progress = Actively working on it\n   - Achieved = Completed milestone\n   - Ongoing = Continuous effort\n4. timeline: Extract year or timeframe (e.g., \"2030\", \"By 2025\", \"Next year\")\n5. metrics_shared: Extract specific numbers (percentages, tons CO2, MW, etc.)\n6. investment_amount: Extract if they mention budget (e.g., \"$100M investment\")\n7. competitive_threat:\n   - High = Ambitious goals, ahead of peers\n   - Medium = Industry standard\n   - Low = Catching up\n8. best_practice:\n   - Yes = Innovative, replicable, industry-leading\n   - No = Standard or company-specific\n\nReturn ONLY the JSON object, no explanations."
            },
            {
              "content": "=Extract ESG initiative intelligence from this LinkedIn post:\n\nCompany: {{ $('Get Dataset Items').item.json.author.name }}\nPost Date: {{ $('Get Dataset Items').item.json.postedAt.date }}\nPost Content: {{ $('Get Dataset Items').item.json.content }}\nEngagement: {{ $('Get Dataset Items').item.json.engagement.likes }} likes, {{ $('Get Dataset Items').item.json.engagement.comments }} comments\n\nReturn only JSON."
            }
          ]
        },
        "builtInTools": {},
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 2.1,
      "position": [
        304,
        -208
      ],
      "id": "f7cc6e88-0be3-45ba-958f-75b08c7e5c5d",
      "name": "AI Extract ESG Intelligence",
      "credentials": {
        "openAiApi": {
          "id": "ICwxUBbatsF2sDvy",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// UNIVERSAL AI RESPONSE PARSER - Same code for ALL cases\nconst items = [];\nconst input = $input.all();\n\nfunction extractJSON(text) {\n  const jsonMatch = text.match(/\\{[\\s\\S]*\\}/);\n  if (!jsonMatch) return null;\n  return jsonMatch[0];\n}\n\ninput.forEach((item, index) => {\n  try {\n    let aiText = item.json.output[0].content[0].text || '';\n    \n    // Clean markdown code blocks\n    aiText = aiText\n      .replace(/```json/gi, '')\n      .replace(/```/g, '')\n      .trim();\n    \n    // Extract JSON object\n    const jsonStr = extractJSON(aiText);\n    \n    if (!jsonStr) {\n      throw new Error('No JSON found in AI response');\n    }\n    \n    // Parse and return clean JSON\n    const parsed = JSON.parse(jsonStr);\n    items.push({ json: parsed });\n    \n  } catch (error) {\n    console.error(`Parse error for item ${index}:`, error.message);\n    // Return empty object on error - no case-specific fields\n    items.push({ json: {} });\n  }\n});\n\nreturn items;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        592,
        -208
      ],
      "id": "98a541c3-4f96-4052-a2b2-fb689510f0e6",
      "name": "Parse AI Response"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "timestamp",
              "name": "analysis_timestamp",
              "value": "={{ new Date().toISOString() }}",
              "type": "string"
            },
            {
              "id": "company_name",
              "name": "company_name",
              "value": "={{ $json.company_name }}",
              "type": "string"
            },
            {
              "id": "initiative_type",
              "name": "initiative_type",
              "value": "={{ $json.initiative_type }}",
              "type": "string"
            },
            {
              "id": "commitment_level",
              "name": "commitment_level",
              "value": "={{ $json.commitment_level }}",
              "type": "string"
            },
            {
              "id": "timeline",
              "name": "timeline",
              "value": "={{ $json.timeline }}",
              "type": "string"
            },
            {
              "id": "metrics",
              "name": "metrics_shared",
              "value": "={{ $json.metrics_shared }}",
              "type": "string"
            },
            {
              "id": "investment",
              "name": "investment_amount",
              "value": "={{ $json.investment_amount }}",
              "type": "string"
            },
            {
              "id": "threat",
              "name": "competitive_threat",
              "value": "={{ $json.competitive_threat }}",
              "type": "string"
            },
            {
              "id": "best_practice",
              "name": "best_practice",
              "value": "={{ $json.best_practice }}",
              "type": "string"
            },
            {
              "id": "company_profile",
              "name": "company_profile",
              "value": "={{ $('Get Dataset Items').item.json.author?.linkedinUrl || '' }}",
              "type": "string"
            },
            {
              "id": "post_content",
              "name": "post_content",
              "value": "={{ $('Get Dataset Items').item.json.content || '' }}",
              "type": "string"
            },
            {
              "id": "post_date",
              "name": "post_date",
              "value": "={{ $('Get Dataset Items').item.json.postedAt?.date || '' }}",
              "type": "string"
            },
            {
              "id": "post_url",
              "name": "post_url",
              "value": "={{ $('Get Dataset Items').item.json.linkedinUrl || '' }}",
              "type": "string"
            },
            {
              "id": "likes",
              "name": "likes_count",
              "value": "={{ $('Get Dataset Items').item.json.engagement?.likes || 0 }}",
              "type": "number"
            },
            {
              "id": "comments",
              "name": "comments_count",
              "value": "={{ $('Get Dataset Items').item.json.engagement?.comments || 0 }}",
              "type": "number"
            },
            {
              "id": "shares",
              "name": "shares_count",
              "value": "={{ $('Get Dataset Items').item.json.engagement?.shares || 0 }}",
              "type": "number"
            },
            {
              "id": "total_engagement",
              "name": "engagement_total",
              "value": "={{ ($('Get Dataset Items').item.json.engagement?.likes || 0) + ($('Get Dataset Items').item.json.engagement?.comments || 0) + ($('Get Dataset Items').item.json.engagement?.shares || 0) }}",
              "type": "number"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        752,
        -208
      ],
      "id": "15959125-25fc-40e4-ac99-414506010065",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "1fCLkcKY4beiCVUbdYyi43xAw_H2076sWm0_C3Cr6-gU",
          "mode": "list",
          "cachedResultName": "Case 82 - ESG Initiative Monitor Log",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fCLkcKY4beiCVUbdYyi43xAw_H2076sWm0_C3Cr6-gU/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fCLkcKY4beiCVUbdYyi43xAw_H2076sWm0_C3Cr6-gU/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Analysis_Date": "={{ $json.analysis_timestamp }}",
            "Company_Name": "={{ $json.company_name }}",
            "Initiative_Type": "={{ $json.initiative_type }}",
            "Commitment_Level": "={{ $json.commitment_level }}",
            "Timeline": "={{ $json.timeline }}",
            "Metrics_Shared": "={{ $json.metrics_shared }}",
            "Investment_Amount": "={{ $json.investment_amount }}",
            "Competitive_Threat": "={{ $json.competitive_threat }}",
            "Best_Practice": "={{ $json.best_practice }}",
            "Company_Profile": "={{ $json.company_profile }}",
            "Post_Date": "={{ $json.post_date }}",
            "Likes": "={{ $json.likes_count }}",
            "Comments": "={{ $json.comments_count }}",
            "Shares": "={{ $json.shares_count }}",
            "Total_Engagement": "={{ $json.engagement_total }}",
            "Post_URL": "={{ $json.post_url }}",
            "Post_Content": "={{ $json.post_content }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Analysis_Date",
              "displayName": "Analysis_Date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Company_Name",
              "displayName": "Company_Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Initiative_Type",
              "displayName": "Initiative_Type",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Commitment_Level",
              "displayName": "Commitment_Level",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Timeline",
              "displayName": "Timeline",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Metrics_Shared",
              "displayName": "Metrics_Shared",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Investment_Amount",
              "displayName": "Investment_Amount",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Competitive_Threat",
              "displayName": "Competitive_Threat",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Best_Practice",
              "displayName": "Best_Practice",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Company_Profile",
              "displayName": "Company_Profile",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Post_Date",
              "displayName": "Post_Date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Likes",
              "displayName": "Likes",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Comments",
              "displayName": "Comments",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Shares",
              "displayName": "Shares",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Total_Engagement",
              "displayName": "Total_Engagement",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Post_URL",
              "displayName": "Post_URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Post_Content",
              "displayName": "Post_Content",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        912,
        -208
      ],
      "id": "7ed62ffc-d810-4542-b8ec-a034823278c8",
      "name": "Log to Google Sheet",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "LOs2dbk9lby0NfDM",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// Aggregate all items from Google Sheets into email-ready summary\nconst allItems = $input.all();\n\n// Count by initiative type\nconst initiativeTypeCounts = {};\nallItems.forEach(item => {\n  const type = item.json.Initiative_Type || 'Other';\n  initiativeTypeCounts[type] = (initiativeTypeCounts[type] || 0) + 1;\n});\n\nconst initiativeBreakdown = Object.entries(initiativeTypeCounts)\n  .sort((a, b) => b[1] - a[1]);\n\n// Count by commitment level\nconst commitmentCounts = {};\nallItems.forEach(item => {\n  const level = item.json.Commitment_Level || 'Unknown';\n  commitmentCounts[level] = (commitmentCounts[level] || 0) + 1;\n});\n\n// Count by competitive threat\nconst threatCounts = {};\nallItems.forEach(item => {\n  const threat = item.json.Competitive_Threat || 'Unknown';\n  threatCounts[threat] = (threatCounts[threat] || 0) + 1;\n});\n\n// Best practices to replicate\nconst bestPractices = allItems.filter(item => \n  item.json.Best_Practice === 'Yes'\n);\n\n// High competitive threat initiatives\nconst highThreats = allItems.filter(item => \n  item.json.Competitive_Threat === 'High'\n);\n\n// Achieved milestones\nconst achievedInitiatives = allItems.filter(item => \n  item.json.Commitment_Level === 'Achieved'\n);\n\n// Companies by initiative count\nconst companyCounts = {};\nallItems.forEach(item => {\n  const company = item.json.Company_Name || 'Unknown';\n  companyCounts[company] = (companyCounts[company] || 0) + 1;\n});\n\nconst topCompanies = Object.entries(companyCounts)\n  .sort((a, b) => b[1] - a[1])\n  .slice(0, 10);\n\n// Build HTML table rows\nconst tableRows = allItems.map(item => {\n  const data = item.json;\n  const threatColor = data.Competitive_Threat === 'High' ? '#dc3545' : \n                      data.Competitive_Threat === 'Medium' ? '#ffc107' : '#28a745';\n  \n  return `\n    <tr>\n      <td>${data.Company_Name || 'N/A'}</td>\n      <td>${data.Initiative_Type || 'N/A'}</td>\n      <td>${data.Commitment_Level || 'N/A'}</td>\n      <td>${data.Timeline || 'N/A'}</td>\n      <td><span style=\"color: ${threatColor}; font-weight: bold;\">${data.Competitive_Threat || 'N/A'}</span></td>\n      <td>${data.Best_Practice || 'N/A'}</td>\n      <td><a href=\"${data.Post_URL || '#'}\">View</a></td>\n    </tr>\n  `;\n}).join('');\n\n// Return single aggregated item\nreturn {\n  json: {\n    week_start: new Date(Date.now() - 7*24*60*60*1000).toISOString().split('T')[0],\n    week_end: new Date().toISOString().split('T')[0],\n    total_initiatives: allItems.length,\n    initiative_breakdown: initiativeBreakdown,\n    commitment_breakdown: Object.entries(commitmentCounts),\n    threat_breakdown: Object.entries(threatCounts),\n    best_practices_count: bestPractices.length,\n    high_threats_count: highThreats.length,\n    achieved_count: achievedInitiatives.length,\n    top_companies: topCompanies,\n    table_rows: tableRows,\n    all_initiatives: allItems.map(item => item.json)\n  }\n};"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1104,
        -208
      ],
      "id": "bd63a2ba-8b5f-4f2a-95fd-05301447c5a3",
      "name": "Aggregate Weekly Summary"
    },
    {
      "parameters": {
        "sendTo": "sustainability-team@yourcompany.com",
        "subject": "=📊 Weekly ESG Intelligence Report: {{ $json.week_start }} to {{ $json.week_end }}",
        "message": "=WEEKLY ESG INITIATIVE INTELLIGENCE REPORT\n================================================\nReport Period: {{ $json.week_start }} to {{ $json.week_end }}\n\nOVERVIEW:\nTotal ESG Initiatives Tracked: {{ $json.total_initiatives }}\nBest Practices Identified: {{ $json.best_practices_count }}\nHigh Competitive Threat: {{ $json.high_threats_count }}\nAchieved Milestones: {{ $json.achieved_count }}\n\nINITIATIVE TYPE BREAKDOWN:\n{{ $json.initiative_breakdown.map(([type, count]) => type + ': ' + count).join('\\n') }}\n\nCOMMITMENT LEVEL:\n{{ $json.commitment_breakdown.map(([level, count]) => level + ': ' + count).join('\\n') }}\n\nCOMPETITIVE THREAT ANALYSIS:\n{{ $json.threat_breakdown.map(([threat, count]) => threat + ': ' + count).join('\\n') }}\n\nMOST ACTIVE COMPANIES:\n{{ $json.top_companies.map(([company, count], i) => (i+1) + '. ' + company + ' (' + count + ' initiatives)').join('\\n') }}\n\n🎯 ACTION REQUIRED:\n⚠️ {{ $json.high_threats_count }} high-threat initiatives - competitors pulling ahead\n✅ {{ $json.best_practices_count }} best practices to evaluate for replication\n\nFull ESG initiative details in Google Sheets.\n\nGenerated: {{ new Date().toLocaleDateString() }}",
        "options": {}
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1296,
        -208
      ],
      "id": "9c7f2231-59b2-4cbd-8550-af7f412a4f95",
      "name": "Send Weekly Summary Email",
      "webhookId": "4a366991-a70c-4710-b118-1c574ca8d3d1",
      "credentials": {
        "gmailOAuth2": {
          "id": "cyqCGWcggZNMcSOv",
          "name": "Gmail account"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "Weekly Schedule - Monday 9 AM": {
      "main": [
        [
          {
            "node": "Scrape LinkedIn ESG Posts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape LinkedIn ESG Posts": {
      "main": [
        [
          {
            "node": "Get Dataset Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Dataset Items": {
      "main": [
        [
          {
            "node": "AI Validation Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Validation Filter": {
      "main": [
        [
          {
            "node": "Parse AI Validation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse AI Validation": {
      "main": [
        [
          {
            "node": "Edit Fields - Validation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields - Validation": {
      "main": [
        [
          {
            "node": "Filter Only ESG Initiatives",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Only ESG Initiatives": {
      "main": [
        [
          {
            "node": "AI Extract ESG Intelligence",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Extract ESG Intelligence": {
      "main": [
        [
          {
            "node": "Parse AI Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse AI Response": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Log to Google Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log to Google Sheet": {
      "main": [
        [
          {
            "node": "Aggregate Weekly Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Weekly Summary": {
      "main": [
        [
          {
            "node": "Send Weekly Summary Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "3a6fa978-7356-474a-87a9-30e203122ca0",
  "meta": {
    "instanceId": "3a43da28588548e21903e71cf1dc3ddd65c24bf0c62e7e4b77542ffe87ad79c6"
  },
  "id": "6SmfQ9kmFXZzIeyL",
  "tags": []
}